<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<input type="button" onclick="f()" value="开始">
<input type="text" id="clock">
<input type="button" onclick="st()" value="结束">
</body>
<script>
    var b= setInterval(f,1000);
    function f(){
        var data=new Date();
       var a= data.toLocaleTimeString();
       let elementById = document.getElementById("clock");
       elementById.value=a;
    }
    function st(){
        clearInterval(b);
    }

</script>
</html>